Fix Lua GC leak: eagerly release C++ refs via tracking lists#90
Draft
mfazekas wants to merge 1 commit intorive-app:mainfrom
Draft
Fix Lua GC leak: eagerly release C++ refs via tracking lists#90mfazekas wants to merge 1 commit intorive-app:mainfrom
mfazekas wants to merge 1 commit intorive-app:mainfrom
Conversation
Sub-artboard scripts store m_context, m_dataRef, m_propertyRefs as independent registry refs via lua_ref(). When the parent artboard is destroyed, only top-level scripts' refs are unreffed — the sub-artboard refs remain as GC roots, keeping C++ objects alive permanently. Track ScriptReffedArtboard and ScriptedViewModel instances in linked lists and null their C++ rcp<> pointers during artboard destruction.
e4651cc to
90cbe04
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lua userdata (ScriptedArtboard, ScriptedViewModel) hold rcp<> refs to C++ objects (DataContext, ViewModelInstance, File) and are stored in the Lua registry as independent GC roots via lua_ref(). When a parent artboard is destroyed, only m_self and m_context are unreffed — but m_dataRef, m_propertyRefs, and m_valueRef remain rooted in the registry, keeping all referenced C++ objects alive permanently. Fix by tracking instances in linked lists and eagerly nullifying their C++ refs before GC.